@echo off
chcp 65001 >nul
echo ========================================
echo    前端HTTP服务器启动脚本
echo ========================================
echo.

:: 检查Node.js是否安装
node --version >nul 2>&1
if errorlevel 1 (
    echo ❌ 未检测到Node.js，请先安装Node.js
    pause
    exit /b 1
)

:: 进入前端目录
cd /d "%~dp0frontend\public"

echo 🌐 正在启动前端HTTP服务器...
echo.

:: 使用Node.js启动简单HTTP服务器
node -e "const http=require('http');const fs=require('fs');const path=require('path');const server=http.createServer((req,res)=>{const file=req.url==='/'?'index.html':req.url.slice(1);const filePath=path.join(__dirname,file);const ext=path.extname(file);const type={'html':'text/html','js':'text/javascript','css':'text/css'}[ext.slice(1)]||'text/plain';fs.readFile(filePath,(err,data)=>{if(err){res.writeHead(404);res.end('Not Found');}else{res.writeHead(200,{'Content-Type':type,'Access-Control-Allow-Origin':'*'});res.end(data);}});});server.listen(8080,()=>{console.log('🚀 前端服务器启动成功!');console.log('📡 服务器地址: http://localhost:8080');console.log('📄 主页: http://localhost:8080/index.html');console.log('📝 提交页面: http://localhost:8080/submit.html');console.log('⏰ 启动时间:',new Date().toLocaleString());console.log('='.repeat(50));console.log('按 Ctrl+C 停止服务器');});"

pause 